<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
<title></title>
	<style>
		.droptarget {
			width: 100px;
			height: 35px;
			margin: 15px;
			padding: 10px;
			border: 1px solid #aaaaaa;
		}
	</style>
</head>
<body>
<p draggable="true" id="dragtarget">拖动到矩形中</p>
<div class="droptarget" ondragover="dragover(event)" ondrop="drop(event)"></div>
<script type="text/javascript">
	var pic = document.getElementById("dragtarget");//获取被拖放的元素
	function dragover(e){
		e.preventDefault();//阻止默认行为，即允许被拖动
	}
	function drop(e){
		e.preventDefault();//阻止默认行为，即允许被拖动
		e.target.appendChild(pic);//移动被拖放的元素
	}
</script>
</body>
</html>
